#include <SDL2/SDL.h>
#include <stdio.h>

#define ERR(msg) do { \
        fprintf(stderr, "%s at %d in %s\n", msg, __LINE__, __FILE__); \
        exit(1); \
    } while (0)

int main(int argc, char **argv)
{
    if (SDL_Init(SDL_INIT_VIDEO) < 0) ERR(SDL_GetError());

    SDL_Window *win = SDL_CreateWindow("demo1", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
    if (!win) ERR(SDL_GetError());

    SDL_Surface *surface = SDL_GetWindowSurface(win);
    if (!surface) ERR(SDL_GetError());

    SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 255, 255, 255));
    SDL_UpdateWindowSurface(win);
    SDL_Delay(3000);

    SDL_DestroyWindow(win);
    SDL_Quit();

    exit(0);
}
